package lime.application;

import lime.application.dialog.LoginDialog;

import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.ui.workbench.lifecycle.ProcessAdditions;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Shell;

public class LifeCycleManager {
	
	@ProcessAdditions
	public void processAdditions(IEclipseContext context) {

		final Shell shell = new Shell(SWT.TOOL | SWT.NO_TRIM);
		LoginDialog dialog = new LoginDialog(shell);
		ContextInjectionFactory.inject(dialog, context);
		
		if (dialog.open() != Window.OK) {
			// close the application
			System.exit(-1);
		}

	}

}
